var http = require('http');
var fs = require('fs');

var server = http.createServer(function(req,res){
    if(req.url == "/CamelliaCity.gltf"){
        fs.readFile("./babylon/CamelliaCity.gltf",function(error,data){
            res.writeHead(200,{"Content-type":"application/gltf","Access-Control-Allow-Origin":"*"});
            res.end(data)    
        });
    }else if(req.url =="/model1"){
        fs.readFile("./babylon/ResidentialBuildings001.gltf",function(error,data){
            res.writeHead(200,{"Content-type":"application/gltf","Access-Control-Allow-Origin":"*"});
            res.end(data)    
        });
    }else if(req.url=="/tree"){

        //tree.js只支持 gltf 2.0格式

        fs.readFile("./three/webgl_loader_gltf.html",function(error,data){
            res.writeHead(200,{"Content-type":"text/html;charset=UTF-8"});
            res.end(data);

        });
    }
    else{
        fs.readFile("./babylon/babylon.html",function(error,data){
            res.writeHead(200,{"Content-type":"text/html;charset=UTF-8"});
            res.end(data);
        });
    }
});
var ip = "172.18.135.1";
var port = 8089;
console.log("http://%s:%d",ip,port);
server.listen(port,ip);
